//
//  DetailViewController.m
//  UISplitViewControllerDemo
//
//  Created by Justsoso on 16/3/10.
//  Copyright © 2016年 Justsoso. All rights reserved.
//

#import "DetailViewController.h"

@interface DetailViewController ()


@property (nonatomic,strong) UIPopoverController *popVC;
@end

@implementation DetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    UIViewController *popContentVC = [[UIViewController alloc] init];
    popContentVC.view.backgroundColor = [UIColor blueColor];
    
    self.popVC = [[UIPopoverController alloc] initWithContentViewController:popContentVC];
    
    self.popVC.popoverContentSize = CGSizeMake(375, 667);
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (IBAction)popBtnPressed:(id)sender
{
    if (self.popVC.popoverVisible)
    {
        [self.popVC dismissPopoverAnimated:YES];
    }
    else
    {
        [self.popVC presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
    }
}
- (IBAction)modelBtnPressed:(id)sender
{
    UIViewController *vc = [[UIViewController alloc] init];
    vc.view.backgroundColor = [UIColor yellowColor];
    
    UIBarButtonItem *rightBtn = [[UIBarButtonItem alloc] initWithTitle:@"关闭" style:UIBarButtonItemStylePlain target:self action:@selector(closeModal)];
    vc.navigationItem.rightBarButtonItem = rightBtn;
    
    UINavigationController *navi = [[UINavigationController alloc] initWithRootViewController:vc];
    
    navi.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
    navi.modalPresentationStyle = UIModalPresentationFormSheet;
    
    [self presentViewController:navi animated:YES completion:nil];
}

- (void)closeModal
{
    [self dismissViewControllerAnimated:YES completion:nil];
}

- (void)setStuName:(NSString *)stuName
{
    _stuName = stuName;
    UILabel *label = [self.view viewWithTag:101];
    label.text = stuName;
}
@end
